﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [System.SerializableAttribute()]
    public class AnonymousSimpleUnion : global::Xtee.Core.Schema.XsdAnySimpleType {
        
        public AnonymousSimpleUnion(global::Kis.Xroad.Eu.SimpleUnion value) : 
                base((System.IComparable)value.Value) {
            this.Validate();
        }
        
        public AnonymousSimpleUnion(global::Kis.Xroad.Eu.DerivedSimpleUnion value) : 
                base((System.IComparable)value.Value) {
            this.Validate();
        }
        
        public AnonymousSimpleUnion(DecimalType0 value) : 
                base((System.Decimal)value) {
            this.Validate();
        }
        
        public AnonymousSimpleUnion(DecimalType1 value) : 
                base((System.Decimal)value) {
            this.Validate();
        }
        
        public AnonymousSimpleUnion() : 
                base(string.Empty) {
        }
        
        public AnonymousSimpleUnion(string value) : 
                base((System.IComparable)Parse(value).Value) {
            this.Validate();
        }
        
        public static bool TryParse(string value, out global::Kis.Xroad.Eu.AnonymousSimpleUnion result) {
            try {
                result = new global::Kis.Xroad.Eu.AnonymousSimpleUnion(value);
                return true;
            }
            catch (System.Exception ) {
                result = null;
                return false;
            }
        }
        
        public static global::Kis.Xroad.Eu.AnonymousSimpleUnion Parse(string value) {
            global::Kis.Xroad.Eu.SimpleUnion _SimpleUnion = null;
            if (global::Kis.Xroad.Eu.SimpleUnion.TryParse(value,out _SimpleUnion)) {
                return new AnonymousSimpleUnion(_SimpleUnion);
            }
            global::Kis.Xroad.Eu.DerivedSimpleUnion _DerivedSimpleUnion = null;
            if (global::Kis.Xroad.Eu.DerivedSimpleUnion.TryParse(value,out _DerivedSimpleUnion)) {
                return new AnonymousSimpleUnion(_DerivedSimpleUnion);
            }
            DecimalType0 _DecimalType0 = null;
            if (DecimalType0.TryParse(value,out _DecimalType0)) {
                return new AnonymousSimpleUnion(_DecimalType0);
            }
            DecimalType1 _DecimalType1 = null;
            if (DecimalType1.TryParse(value,out _DecimalType1)) {
                return new AnonymousSimpleUnion(_DecimalType1);
            }
             throw new FormatException("Cannot parse to type [global::Kis.Xroad.Eu.AnonymousSimpleUnion] from string value : [" + value + "]");;
        }
        
        [System.SerializableAttribute()]
        public class DecimalType0 : global::Xtee.Core.Schema.XsdInteger {
            
            public DecimalType0(decimal value) : 
                    base(value) {
                this.SuuremVordneKui = (System.Decimal)0;
                this.VaiksemVordneKui = (System.Decimal)100;
                this.Validate();
            }
            
            public DecimalType0(string value) : 
                    base(value) {
                this.SuuremVordneKui = (System.Decimal)0;
                this.VaiksemVordneKui = (System.Decimal)100;
                this.Validate();
            }
            
            public DecimalType0() : 
                    base(new decimal()) {
            }
            
            public static bool TryParse(string value, out DecimalType0 result) {
                try {
                    result = new DecimalType0(value);
                    return true;
                }
                catch (System.Exception ) {
                    result = null;
                    return false;
                }
            }
            
            public static implicit operator Decimal (DecimalType0 value) {
                return value.Value;
            }
            
            public static implicit operator DecimalType0 (decimal value) {
                return new DecimalType0(value);
            }
        }
        
        [System.SerializableAttribute()]
        public class DecimalType1 : global::Xtee.Core.Schema.XsdInteger {
            
            public DecimalType1(decimal value) : 
                    base(value) {
                this.SuuremVordneKui = (System.Decimal)300;
                this.VaiksemVordneKui = (System.Decimal)400;
                this.Validate();
            }
            
            public DecimalType1(string value) : 
                    base(value) {
                this.SuuremVordneKui = (System.Decimal)300;
                this.VaiksemVordneKui = (System.Decimal)400;
                this.Validate();
            }
            
            public DecimalType1() : 
                    base(new decimal()) {
            }
            
            public static bool TryParse(string value, out DecimalType1 result) {
                try {
                    result = new DecimalType1(value);
                    return true;
                }
                catch (System.Exception ) {
                    result = null;
                    return false;
                }
            }
            
            public static implicit operator Decimal (DecimalType1 value) {
                return value.Value;
            }
            
            public static implicit operator DecimalType1 (decimal value) {
                return new DecimalType1(value);
            }
        }
    }
}
